﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tasks.Common.Entitys;
using Tasks.Dao;

namespace Tasks.Business
{
    public class DictBLL
    {
        /// <summary>
        /// 按字典关键字查找字典值
        /// </summary>
        /// <param name="dictKey"></param>
        /// <param name="ownerID"></param>
        /// <returns></returns>
        public IList<DictValue> GetDictsKeyValueByOwnerID(string dictKey, int ownerID)
        {
            return new DictValueDao().FindKeyValueByOwnerID(dictKey, ownerID);
        }

        /// <summary>
        /// 字典名称
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public DictGroup GetDictGroupByKey(string key)
        {
            return new DictGroupDao().Find(key);
        }

        /// <summary>
        /// 按字典关键字查找字典值
        /// </summary>
        /// <param name="dictKey"></param>
        /// <param name="ownerID"></param>
        /// <returns></returns>
        public IList<DictValue> GetDictsByDictKey(string dictKey, int ownerID)
        {
            return new DictValueDao().FindByDictKey(dictKey, ownerID);
        }

        /// <summary>
        /// 更新键值表
        /// </summary>
        /// <param name="dictKey"></param>
        /// <param name="ownerID"></param>
        /// <param name="dicts"></param>
        public void UpdateKeyValue(string dictKey, int ownerID, IList<DictValue> dicts)
        {
            new DictValueDao().UpdateKeyValue(dictKey, ownerID, dicts);
        }
    }
}
